package com.bibrApp.difu.fragment.wallet_mvp;

import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bibrApp.difu.R;
import com.bibrApp.difu.fragment.cloudwallet_mvp.CloudWalletBean;
import com.bibrApp.difu.utils.BigdecimalUtils;
import com.bibrApp.difu.utils.UIUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.ArrayList;

public class CloudWalletAdapter extends BaseQuickAdapter<CloudWalletBean, BaseViewHolder> {
    private int mType = 0;//云 多 合
    public CloudWalletAdapter() {
        super(R.layout.item_cloudwallet, new ArrayList<>());
    }
    public void setType(int type){
        mType = type;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, CloudWalletBean item) {

        TextView tvType = helper.getView(R.id.item_type);
        if (item.getCoinEunit().equals("BTC")) {
            UIUtils.setDrawableLeft(tvType, R.mipmap.img_btc_28);
            helper.setText(R.id.item_typename, "比特币");
            helper.setVisible(R.id.tv_jiedai,true);
            helper.setVisible(R.id.tv_tibi,true);
            helper.setVisible(R.id.tv_chongzhi,true);
            helper.setText(R.id.tv_totle, String.valueOf(BigdecimalUtils.getBigDecimalPrice(item.getConvertTotalMoney(),8)));
        } else if (item.getCoinEunit().equals("USDT")) {
            UIUtils.setDrawableLeft(tvType, R.mipmap.img_usdt_28);
            helper.setText(R.id.item_typename, "Tether");
            helper.setVisible(R.id.tv_jiedai,false);
            helper.setVisible(R.id.tv_chongzhi,mType != 2);
            helper.setVisible(R.id.tv_tibi,true);
            helper.setText(R.id.tv_totle, String.valueOf(BigdecimalUtils.getBigDecimalPrice(item.getConvertTotalMoney(),2)));
        } else {
            UIUtils.setDrawableLeft(tvType, R.mipmap.img_eth_28);
            helper.setText(R.id.item_typename, "以太币");
            helper.setVisible(R.id.tv_jiedai,false);
            helper.setVisible(R.id.tv_tibi,true);
            helper.setVisible(R.id.tv_chongzhi,true);
            helper.setText(R.id.tv_totle, String.valueOf(BigdecimalUtils.getBigDecimalPrice(item.getConvertTotalMoney(),3)));
        }
        tvType.setText(item.getCoinEunit());
        helper.setText(R.id.tv_keyong, item.getHotMoney());
        helper.setText(R.id.tv_diya, item.getColdMoney());

        helper.addOnClickListener(R.id.tv_chongzhi, R.id.tv_tibi, R.id.tv_jiedai);
    }
}
